﻿using MongoDB.Driver;
using Sustainalytics.Entities;
using System.Collections.Generic;
using System.Linq;

namespace Sustainalytics.ScreeningTool.Synchronization.Handlers.RiskRatings
{
    public class GovernancePillarsHandler : IHandlerWithGrouping<GovernancePillars>
    {
        public ProjectionDefinition<GovernancePillars> GetProjection(ProjectionDefinitionBuilder<GovernancePillars> builder) => builder
            .Include(x => x.Name)
            .Include(x => x.Comment)
            .Include(x => x.Score);

        public IEnumerable<ExtraElement> GetExtraElements(IEnumerable<GovernancePillars> entities)
            => entities.SelectMany(entity => new ExtraElementList
            {
                { $"{entity.Name}-Commentary-RR", entity.Comment },
                { $"{entity.Name}-Score-RR", entity.Score }
            });
    }
}
